package com.lagou.wwyan.rpc.config;

import com.lagou.wwyan.rpc.server.RpcServer;
import com.lagou.wwyan.rpc.server.factory.RpcBeanFactory;
import com.lagou.wwyan.rpc.server.factory.SpringRpcBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RpcConfig {
    @Bean
    public RpcBeanFactory rpcBeanFactory(){
        return new SpringRpcBeanFactory();
    }
    @Bean
    public RpcServer rpcServer(RpcBeanFactory beanFactory) throws InterruptedException {
        RpcServer rpcServer = new RpcServer(beanFactory);
        rpcServer.startServer("127.0.0.1",9999);
        return rpcServer;
    }
}
